import React, { forwardRef } from 'react';
import * as TooltipPrimitive from '@radix-ui/react-tooltip';

// TooltipProvider组件
const TooltipProvider = TooltipPrimitive.Provider;

// Tooltip组件
const Tooltip = TooltipPrimitive.Root;

// TooltipContent组件
const TooltipContent = forwardRef<HTMLDivElement, TooltipPrimitive.TooltipContentProps>(({ className, sideOffset = 4, ...props }, ref) => (
  <TooltipPrimitive.Content
    ref={ref}
    sideOffset={sideOffset}
    className={`z-50 overflow-hidden rounded-md border bg-popover px-3 py-1.5 text-sm text-popover-foreground shadow-md animate-in fade-in-0 zoom-in-95 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 ${className}`}
    {...props}
  />
));

// TooltipTrigger组件
const TooltipTrigger = TooltipPrimitive.Trigger;

// TooltipArrow组件
const TooltipArrow = forwardRef<SVGSVGElement, TooltipPrimitive.TooltipArrowProps>(({ className, ...props }, ref) => (
  <TooltipPrimitive.Arrow
    ref={ref}
    className={`fill-popover border-current ${className}`}
    {...props}
  />
));

// TooltipGroup组件
const TooltipGroup = TooltipPrimitive.Group;

// 导出所有组件
export {
  Tooltip,
  TooltipArrow,
  TooltipContent,
  TooltipGroup,
  TooltipProvider,
  TooltipTrigger,
};